//
//  AppDelegate.m
//  徙游记-01
//
//  Created by hcios on 2017/6/22.
//  Copyright © 2017年 鹿林. All rights reserved.
//

#import "AppDelegate.h"
#import "XYJTabBarViewController.h"
#import <UMSocialCore/UMSocialCore.h>
#import "UMSocialWechatHandler.h"
#import "StartMovieViewController.h"
#import "XYJTabBarViewController.h"
//#import "FLEXManager.h"
@interface AppDelegate ()

@property (nonatomic,strong) XYJTabBarViewController *tabBarViewController;

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    self.tabBarViewController = [[XYJTabBarViewController alloc] init];
    
    //1.设置根控制器
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    //登录判断
    [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"isFirstLogin"];
    BOOL isFirstLogin = [[[NSUserDefaults standardUserDefaults] objectForKey:@"isFirstLogin"] boolValue];
    if (isFirstLogin == YES) {
        StartMovieViewController *VC = [[StartMovieViewController alloc] init];
        VC.movieURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"qidong" ofType:@"mp4"]];
        self.window.rootViewController = VC;
        [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"isFirstLogin"];
    }else{
        self.window.rootViewController = self.tabBarViewController;
    }
    
    [self.window makeKeyAndVisible];
    
    
    //控件外观设置
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    
    //2.设置nav的字体颜色
    NSDictionary *navbarTitleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    [[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
    [[UITabBar appearance] setTintColor:RGB(30, 144, 255)];
    
    //3.设置nav的背景颜色
    [[UINavigationBar appearance] setBarTintColor:RGB(30, 144, 255)];
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
    
    [[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setAlpha:0.6];
    
    [[UITableViewCell appearance] setBackgroundColor:RGB(230, 241, 243)];
    
    [[UIScrollView appearance] setBackgroundColor:RGB(230, 241, 243)];
    
    
    //关闭半透明效果
    [UITabBar appearance].translucent = NO;
    
    
    //4.设置电池栏样式
    application.statusBarStyle = UIStatusBarStyleLightContent;
    
    
    //5.分享控件设置
    UIMenuController *menuController = [UIMenuController sharedMenuController];
    
    [menuController setMenuVisible:YES animated:YES];
    [menuController setMenuItems:@[
                                   [[UIMenuItem alloc] initWithTitle:@"复制" action:NSSelectorFromString(@"copyText:")],
                                   [[UIMenuItem alloc] initWithTitle:@"删除" action:NSSelectorFromString(@"deleteObject:")]
                                   ]];
     
    [[UMSocialManager defaultManager] openLog:YES];
    [[UMSocialManager defaultManager] setUmSocialAppkey:@"5850fb5f9f06fd2dba001c1e"];
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:@"wx0f2fe1ea66ec1c5b" appSecret:@"2b60f048e71559a2f67001331bf9709a" redirectURL:@"http://mobile.umeng.com/social"];
    
    return YES;
}

//回调
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
    BOOL result = [[UMSocialManager defaultManager] handleOpenURL:url];
    if (!result) {
        //其他如支付宝等SDK的回调
    }
    return result;
}

//-(void)ll_initFlex{
//#if DEBUG
//    [[FLEXManager sharedManager] showExplorer];
//#endif
//}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
